#include "Uuid.h"

#include <string.h>
#include <fan-llvm/core/Core.h>
#include "Type.h"
#include "UnsupportedErr.h"


Type* Uuid_classType = NULL;
VTable* Uuid_classVTable = NULL;


/**********************************************
 *
 * Methods and fields
 *
 **********************************************/


/* Bool equals(Obj? that) */
Bool Uuid_equals(Obj self, NullableObj that)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Uuid.equals not implemented yet"));
}


/* Int compare(Obj that) */
Int Uuid_compare(Obj self, Obj that)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Uuid.compare not implemented yet"));
}


/* Int hash() */
Int Uuid_hash(Obj self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Uuid.hash not implemented yet"));
}


/* Str toStr() */
Str* Uuid_toStr(Obj self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Uuid.toStr not implemented yet"));
}


/* Uuid make() */
Uuid* Uuid_make(void)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Uuid.make not implemented yet"));
}


/* Uuid makeBits(Int hi, Int lo) */
Uuid* Uuid_makeBits(Int hi, Int lo)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Uuid.makeBits not implemented yet"));
}


/* Uuid? fromStr(Str s, Bool checked) */
Uuid* Uuid_fromStr_1(Str* s)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Uuid.fromStr not implemented yet"));
}


/* Uuid? fromStr(Str s, Bool checked) */
Uuid* Uuid_fromStr(Str* s, Bool checked)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Uuid.fromStr not implemented yet"));
}


/* Int bitsHi() */
Int Uuid_bitsHi(Uuid* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Uuid.bitsHi not implemented yet"));
}


/* Int bitsLo() */
Int Uuid_bitsLo(Uuid* self)
{
  exceptionThrow(UnsupportedErr_newWithFormattedMsg("sys::Uuid.bitsLo not implemented yet"));
}


/**********************************************
 *
 * Type-system functions
 *
 **********************************************/


Type* Uuid_initType(void)
{
  if (Uuid_classType == NULL)
  {
    Type* baseType = Obj_initType();
    VTable* vtable = Uuid_initVTable();
    Type* type = Type_new("Uuid", baseType, vtable, sizeof(Uuid), sizeof(UuidVTable));
    Type_registerMethodImplementation(type, "bitsHi", Uuid_bitsHi, 0);
    Type_registerMethodImplementation(type, "bitsLo", Uuid_bitsLo, 0);
    Type_registerMethodImplementation(type, "compare", Uuid_compare, 1);
    Type_registerMethodImplementation(type, "equals", Uuid_equals, 1);
    Type_registerMethodImplementation(type, "fromStr", Uuid_fromStr_1, 1);
    Type_registerMethodImplementation(type, "fromStr", Uuid_fromStr, 2);
    Type_registerMethodImplementation(type, "hash", Uuid_hash, 0);
    Type_registerMethodImplementation(type, "make", Uuid_make, 0);
    Type_registerMethodImplementation(type, "makeBits", Uuid_makeBits, 2);
    Type_registerMethodImplementation(type, "toStr", Uuid_toStr, 0);
    Uuid_classType = type;
    Uuid_initStatic();
  }
  return Uuid_classType;
}


VTable* Uuid_initVTable(void)
{
  if (Uuid_classVTable == NULL)
  {
    VTable* vtable = memoryAlloc(sizeof(UuidVTable));
    memcpy(vtable, Obj_initVTable(), sizeof(FanObjVTable));
    ((FanObjVTable*)vtable)->compare = Uuid_compare;
    ((FanObjVTable*)vtable)->equals = Uuid_equals;
    ((FanObjVTable*)vtable)->hash = Uuid_hash;
    ((FanObjVTable*)vtable)->toStr = Uuid_toStr;
    Uuid_classVTable = vtable;
  }
  return Uuid_classVTable;
}


void Uuid_initStatic(void)
{
}
